package com.huanglexin.framework.util;

import java.util.Objects;

/**
 * @author Huang Lexin
 * @date 2021年11月22日 8:31
 */
public class StringUtil {
    private StringUtil() {

    }

    static class IllgalTypeNameException extends RuntimeException {
        public IllgalTypeNameException(String message) {
            super(message);
        }
    }

    public static String beanNameFor(String typeName) {
        Objects.requireNonNull(typeName);
        if (0 == typeName.length()) {
            throw new IllgalTypeNameException("typeName 不能为空!");
        }
        char[] chars = typeName.toCharArray();
        char c = chars[0];
        chars[0] = c >= 'A' && c <= 'Z' ? (char)(c - 'A' + 'a') : c;
        return new String(chars);
    }
}
